﻿using System;
using ASPNETVN.PORTAL.Components.Helpers;
using ASPNETVN.PORTAL.Components.UI;

namespace LMHTX.Modules.DIRECTORY.COOPERATIVE
{
    public enum ModulePages
    {
        AddEditItem,
        CooperativeStatistics, 
        CooperativeStatistics2,
        CooperativeSearch,
        CooperativeList,
        CooperativeDetail
    }    

    public partial class Main : PortalModuleControl
    { 

        protected void Page_Load(object sender, EventArgs e)
        {
            this.LoadChildControl();
            this.ModuleTitle.AddUrl = HttpUrlBuilder.BuildAddEditUrl(this.ModuleID, 0, "AddEditItem");    
        }
        private void LoadChildControl()
        {
            const string basePath = "~/Modules/LMHTX.Modules.DIRECTORY.COOPERATIVE/";
            const string pageQuery = "page";
            string pageName = Request.QueryString[pageQuery];

            ModulePages page = ModulePages.CooperativeList;
            if (pageName != null)
            {
                page = (ModulePages)Enum.Parse(typeof(ModulePages), Request.QueryString[pageQuery], true);
            }

            string src = string.Format("{0}Controls/{1}.ascx", basePath, page);
            ModulePage ctl = (ModulePage)this.LoadControl(src);
            ctl.ParentControl = this;
            ContentPane.Controls.Add(ctl);
        }

    }
}